package wsz.queue;

import com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer;
import com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer;
import com.alibaba.rocketmq.client.consumer.PullResult;
import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import com.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import com.alibaba.rocketmq.common.message.MessageExt;
import com.alibaba.rocketmq.common.message.MessageQueue;

import java.io.UnsupportedEncodingException;

/**
 * 消费者指定主题的queue
 * @author wsz
 * @date 2022/2/23 15:14
 **/
public class Consumer {

    public static void main(String[] args) throws Exception {
        DefaultMQPullConsumer consumer = new DefaultMQPullConsumer("consumer_grp_wsz");
        consumer.setNamesrvAddr("192.168.174.138:9876");
        consumer.start();
        // 读取指定topic下的queue中的数据
        PullResult pull = consumer.pull(
                new MessageQueue("tp_queue_select", "localhost.localdomain", 1),
                "*",
                0,
                10);
        // PullResult [pullStatus=FOUND, nextBeginOffset=1, minOffset=0, maxOffset=1, msgFoundList=1]
        System.out.println(pull);
        consumer.shutdown();
    }
}
